package LeetCode.month04.day92;

/**
 * @author 16778
 * @date 2025/11/1 8:15
 * @description
 */
public class No203 {
    public ListNode removeElements(ListNode head, int val) {
        ListNode root = new ListNode();
        ListNode curr = root;
        while(head!=null){
            if(head.val!=val){
                curr.next = new ListNode(head.val);
                curr = curr.next;
            }
            head = head.next;
        }
        return root.next;
    }
}